package com.yan.test.fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.yan.jackson.Student;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

/**
 * @author taoge
 * @Date 2024/8/13 18:45
 * @Description
 */
public class FastJson {
    public static void main(String[] args) throws IOException {
        // Book{title='java', author='james gosling', year=1995, price=50.0}
        Book book = new Book("java", "james gosling", 1995, 50.0);
        //Book{title='harrypotter', author='rowling', year=2000, price=29.99}
        Book book1 = new Book("happypotter", "rowling", 2000, 29.99);
        List<Book> list = new LinkedList<>();
        list.add(book);
        list.add(book1);
        String newList = JSON.toJSONString(list);
        FileWriter fw = new FileWriter("day18_code/src/com/yan/test/fastjson/books.json");
        fw.write(newList);
        fw.close();
    }
}
